package com.demo.service;


import com.demo.database.data.User;
import com.demo.database.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;

    @Transactional(rollbackFor = Exception.class)
    public void testInsert(){
        User user = new User();
        user.setUserName("www");
        user.setId(2L);
        user.setEnabled((byte) 0);
        user.setPasssword("123");
        user.setLocked((byte) 0);
        userMapper.insert(user);
        User user1 = new User();
        user1.setUserName("www2");
        user1.setId(3L);
        user1.setEnabled((byte) 0);
        user1.setPasssword("1223");
        user1.setLocked((byte) 0);
        int w = 1 / 0;

        userMapper.insert(user1);
    }
}
